package com.letoo.dragon.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.letoo.dragon.interceptor.AuthInterceptor;

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

	/**
	 * 默认为线上环境
	 */
	@Value("${auth.api.authUrl}")
	private String AUTH_URL;
	/**
	 * 需要排除的URL
	 */
	@Value("${auth.api.excludedUrl}")
	private String excludedUrl;
	@Value("${auth.api.isValidate}")
	private boolean isValidate;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//注册权限拦截器
		registry.addInterceptor(new AuthInterceptor(AUTH_URL, excludedUrl, isValidate)).addPathPatterns("/ext/**");
		super.addInterceptors(registry);
	}
}
